import { createRouter, createWebHistory } from 'vue-router'
import login from '../views/login.vue'
import home from '../views/home.vue'
import page404 from '../views/errorPage/page404.vue'

const whiteRoutes = [
  {
    path: '/',
    name: 'default',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/home',
    name: 'home',
    component: home,
    children: [
      {
        path: '/menuManage',
        name: 'menuManage',
        component: () => import('../views/admin/menuManage.vue')
      },
      {
        path: '/userManage',
        name: 'userManage',
        component: () => import('../views/admin/userManage.vue')
      },
      {
        path: '/mineSweeping',
        name: 'mineSweeping',
        component: () => import('../views/common/game/mineSweeping.vue')
      },
      {
        path: '/gomoku',
        name: 'gomoku',
        component: () => import('../views/common/game/gomoku.vue')
      },
      {
        path: '/dingding',
        name: 'dingding',
        component: () => import('../views/common/daily/dingding.vue')
      }
    ]
  },
]
const errorRoutes = [
  {
    path: '/:pathMatch(.*)*',
    name: 'page404',
    component: page404
  },
]
const routes = whiteRoutes.concat(errorRoutes);
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
